﻿using Api.Model;
using Api.ContentProvider;
using Core.Infrastructure.Settings;
using Microsoft.Practices.Unity;
using Core.Infrastructure.AnimationService;
using TypeMock.ArrangeActAssert;
using Microsoft.Practices.Composite.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Core.ScreenStore.ViewModel;
using CThru.Silverlight;

namespace Core.ScreenStore.Test
{
    [TestFixture]
    class ArticleDetailsViewModelTest
    {
        [SilverlightUnitTest]
        [Test]
        public void OnNavigate_Article_IsNotNull()
        {
            Article fakeArticle = Isolate.Fake.Instance<Article>();
            IContentProvider fakeIContentProvider = Isolate.Fake.Instance<IContentProvider>();
            ISettings fakeISettings = Isolate.Fake.Instance<ISettings>();
            IUnityContainer fakeIUnityContainer = Isolate.Fake.Instance<IUnityContainer>();
            IAnimationService fakeIAnimationService = Isolate.Fake.Instance<IAnimationService>();
            IEventAggregator fakeIEventAggregator = Isolate.Fake.Instance<IEventAggregator>();
            var viewModel = new ArticleDetailsViewModel(fakeIEventAggregator, fakeIAnimationService, fakeIUnityContainer, fakeISettings, fakeIContentProvider, null);

            viewModel.OnNavigate(fakeArticle);

            Assert.IsNotNull(viewModel.Article);
        }

        [SilverlightUnitTest]
        [Test]
        public void OnNavigate_Article_NullReferenceException()
        {
            Article fakeArticle = Isolate.Fake.Instance<Article>();
            IContentProvider fakeIContentProvider = Isolate.Fake.Instance<IContentProvider>();
            ISettings fakeISettings = Isolate.Fake.Instance<ISettings>();
            IUnityContainer fakeIUnityContainer = Isolate.Fake.Instance<IUnityContainer>();
            IAnimationService fakeIAnimationService = Isolate.Fake.Instance<IAnimationService>();
            IEventAggregator fakeIEventAggregator = Isolate.Fake.Instance<IEventAggregator>();
            var viewModel = new ArticleDetailsViewModel(fakeIEventAggregator, fakeIAnimationService, fakeIUnityContainer, fakeISettings, fakeIContentProvider, null);

            Assert.Throws<NullReferenceException>(()
                => viewModel.Article.ToString());
        }
    }
}
